﻿Public Class LABITEM
    Dim connect As CONDB = CONDB.NewConnection()
    Dim PROVIDER_Check As New PROVIDERSCLASS

    Private Sub LABITEM_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim objSelectDataLab_item_type As New lab_item_type
        Dim lab_item_typeData As DataTable
        lab_item_typeData = connect.GetTable(objSelectDataLab_item_type.selectLabItemType_)
        'masgrpdrgData = connectlocal.GetTable(objSelectDataMasgrpdrg.selectMasgrpdrg_)
        lab_item_typeGrid.PrimaryGrid.DataSource = lab_item_typeData

        DesignForm(Me)
        DesignGrid(lab_item_typeGrid)

        PROVIDER_Check.GETHOSEM(CInt(main.txtUserRequest.Text.Trim), Convert.ToString(Me.Tag))
    End Sub

    Private Sub lab_item_typeGrid_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles lab_item_typeGrid.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow
        'f.TXT_CID.Text = grid.Cells.Item(2).Value
        lab_item_type_codeTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส lab item").Value()
        lab_item_type_nameTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ชื่อ lab item").Value()

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("คำอธิบาย lab item").Value().ToString.Length > 0 Then
            commentLabitemtypeTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("คำอธิบาย lab item").Value()
        Else
            commentLabitemtypeTxt.Text = ""
        End If
        'commentLabitemtypeTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("คำอธิบาย lab item").Value()

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("wbc diff").Value() = True Then
            wbc_diffLabitemtypeChk.Checked = True
        Else
            wbc_diffLabitemtypeChk.Checked = False
        End If
    End Sub

    Private Sub addLabitemtype_Click(sender As Object, e As EventArgs) Handles addLabitemtype.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PADD_ = True Then
                If lab_item_type_nameTxt.Text.ToString.Length > 0 Then
                    Dim objInsertData As New lab_item_type
                    objInsertData.lab_item_type_name_ = lab_item_type_nameTxt.Text
                    objInsertData.comment_ = commentLabitemtypeTxt.Text
                    objInsertData.wbc_diff_ = wbc_diffLabitemtypeChk.Checked
                    objInsertData.insertLabItemTypeData()

                    Dim objSelectDataLab_item_type As New lab_item_type
                    Dim lab_item_typeData As DataTable
                    lab_item_typeData = connect.GetTable(objSelectDataLab_item_type.selectLabItemType_)
                    'masgrpdrgData = connectlocal.GetTable(objSelectDataMasgrpdrg.selectMasgrpdrg_)
                    lab_item_typeGrid.PrimaryGrid.DataSource = lab_item_typeData

                    lab_item_type_codeTxt.Text = ""
                    lab_item_type_nameTxt.Text = ""
                    commentLabitemtypeTxt.Text = ""
                    wbc_diffLabitemtypeChk.Checked = False
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PADDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub editLabitemtype_Click(sender As Object, e As EventArgs) Handles editLabitemtype.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PUPD_ = True Then
                If lab_item_type_nameTxt.Text.ToString.Length > 0 Then
                    Dim editStat As Integer
                    editStat = MsgBox("ท่านต้องการแก้ไขข้อมูลกลุ่ม lab item ดังกล่าวใช่หรือไม่", MsgBoxStyle.OkCancel)

                    If editStat = 1 Then
                        Dim objEditData As New lab_item_type
                        objEditData.lab_item_type_code_ = lab_item_type_codeTxt.Text
                        objEditData.lab_item_type_name_ = lab_item_type_nameTxt.Text
                        objEditData.comment_ = commentLabitemtypeTxt.Text
                        objEditData.wbc_diff_ = wbc_diffLabitemtypeChk.Checked
                        objEditData.editLabItemTypeData()

                        Dim objSelectDataLab_item_type As New lab_item_type
                        Dim lab_item_typeData As DataTable
                        lab_item_typeData = connect.GetTable(objSelectDataLab_item_type.selectLabItemType_)
                        'masgrpdrgData = connectlocal.GetTable(objSelectDataMasgrpdrg.selectMasgrpdrg_)
                        lab_item_typeGrid.PrimaryGrid.DataSource = lab_item_typeData

                        lab_item_type_codeTxt.Text = ""
                        lab_item_type_nameTxt.Text = ""
                        commentLabitemtypeTxt.Text = ""
                        wbc_diffLabitemtypeChk.Checked = False
                    End If
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PUPDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub importExel_Click(sender As Object, e As EventArgs) Handles importExel.Click
        Dim nextform As New IMPORTEXCEL("lab_item_type")
        nextform.ShowDialog()
    End Sub

    Private Sub exportExcel_Click(sender As Object, e As EventArgs) Handles exportExcel.Click
        Dim nextform As New IMPORTEXCEL("lab_item_type")
        nextform.ShowDialog()
    End Sub
End Class